package com.cungmua.app.model.request;

import com.cungmua.app.model.User;
import com.cungmua.app.utils.AppUtils;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonUnwrapped;

/**
 * Created by kelvin.nguyen on 7/1/14.
 */
public class RegisterRequest extends AuthenticatedRequest {
    private User user;
    private String password;

    public RegisterRequest(String deviceId, String token) {
        super(deviceId, token);
    }

    @JsonUnwrapped
    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    @JsonProperty("Password")
    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    @Override
    public String getSign() {
        String dob = AppUtils.getServerDateFormatter().format(user.getDateOfBirth());
        return AppUtils.MD5(user.getEmail() + getPassword() + user.getName() + user.getMobile() +
                dob + user.getGender() + getVersion() + getDeviceId() + getToken());
    }
}

